/********************************************************************************
 * Project Name		[JavaSE_Fundamentals]
 * File Name     	[ThreadApi.java]
 * Creation Date 	[2015-01-01]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ********************************************************************************/
package thread;

/**
 * @author 不落的太阳(Sean Yang aka ShortPeace)
 * @version 1.0
 * @since jdk 1.8
 * 
 */
public class ThreadApi {

	public static void main(String[] args) {
		MyThread03 t1 = new MyThread03();
		t1.setName("T1"); // 设置线程的名称
		t1.start();

		MyThread03 t2 = new MyThread03();
		t2.setName("T2");
		t2.start();

		t2.setPriority(8); // 设置线程的优先级
		System.out.println("Thread T2的优先级: " + t2.getPriority()); // 获取线程的优先级

		// 获得main线程的优先级
		System.out.println("Thread Main的优先级: " + Thread.currentThread().getPriority());
	}
}

/**
 * 
 * @author 不落的太阳(Sean Yang aka ShortPeace)
 * @version 1.0
 * @since jdk 1.8
 *
 */
class MyThread03 extends Thread {

	@Override
	public void run() {
		System.out.println("thread is running --->" + Thread.currentThread().getName());
		// Thread.currentThread() 返回当前的线程对象
		// getName() 获取当前线程的名称

		try {
			Thread.sleep(3000); // 当前线程睡眠指定的毫秒数
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}